package cn.tedu.d21_socket;

import java.io.*;
import java.net.Socket;
import java.util.Scanner;

/**
 Socket-用户端
 */
public class Client {
    public static void main(String[] args) throws Exception {

        Socket s=new Socket("172.199.11.43",8888);//127.0.0.1 访问自己的IP
        System.out.println("连接成功.");

        BufferedReader br=new BufferedReader(
                new InputStreamReader(s.getInputStream()));

        PrintWriter pw=new PrintWriter(s.getOutputStream(),true);


        while(true) {
            System.out.print("我:");
            String str = new Scanner(System.in).nextLine();
            pw.println(str);
            //pw.flush();
//            out.write(str.getBytes());
//            out.flush();

            //System.out.println("");
 /*           for (int i = 0; i <5; i++) {
                char a = (char) in.read();
                System.out.print(a);
            }*/

            String ss=br.readLine();
            System.out.print(ss);

            System.out.print(" :淘宝");

            System.out.println();
        }

        //out.close();flush+close
        //out.flush();//刷新数据







    }
}
